<template>
  <div>
    <!--<div style="margin-bottom:15px">
      <el-button
        slot="addOrder"
        style="background: rgb(7, 131, 241);color: #fff"
        @click="$router.push('addexapply')"
      >
      样品申请
      </el-button>
    </div>-->
    <div class="applicationList">
      <el-table :data="tableData" style="width: 100%" height="500" stripe>
        <el-table-column prop="recordNum" label="订单编号"></el-table-column>
        <el-table-column prop="company" label="收件人"></el-table-column>
        <el-table-column prop="mobile" label="联系方式"></el-table-column>
        <el-table-column prop="companyAddress" label="收货地址"></el-table-column>
        <el-table-column prop="productStoreName" label="设备名称"></el-table-column>
        <el-table-column prop="createTime" label="建立时间">
          <template slot-scope="scope">
            <label>{{scope.row.createTime | formatDate}}</label>
          </template>
        </el-table-column>
        <el-table-column prop="status" label="状态" :formatter="formatStatus"></el-table-column>
      </el-table>
      <el-pagination
        style="text-align:right;margin-top:20px"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { SAMPLE_MY_LIST } from '@/utils/api';
import search from "@/components/search.vue";
import { formatDate } from '@/utils/validate.js';
export default {
  components: { search },
  data() {
    return {
      searchForm: {
        customerName: "",
        materialNo: "",
        applicant: "",
        timeRange: [],
        status: ""
      },
      tableData: [
        
      ],
      currentPage: 1,
      pageSize: 10,
      total: 50
    };
  },
  created(){
    this.getSampleMyList()
  },
    filters: {
		    formatDate(time) {
            var date = new Date(time*1000);
		        return formatDate(date, 'yyyy-MM-dd hh:mm:ss');
		    }
		  },
  methods: {
    search() {},
    getSampleMyList(){
      console.log('==getSampleMyList==>')
      SAMPLE_MY_LIST({ 
          pageNo: this.currentPage,
          pageSize: this.pageSize
      }).then(res => {
          this.loading = false
          this.tableData = res.data.dataList
          this.total = res.data.count
      })
    },
    // 订单状态格式化
    formatStatus(row, column) {
      var status = row[column.property]
      switch(status) {
        case 0: return '审核中'
        case 1: return '待发货'
        case 2: return '拒绝提供'
        case 3: return '已发货'
        case 4: return '已到货'
        default: return '未知'
      }
    },
    checkTransport(row, index) {
      this.$router.push('transportation')
    },
    modifyOrder(row, index) {
      this.$router.push({
        name: "handleOrder",
        params: {
          orderIndo: row
        }
      });
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    }
  }
};
</script>

<style lang="scss" scoped>
.applicationList {
  width: 100%;
  background: #fff;
  padding: 20px 2px;
  border-radius: 5px;
  box-shadow: 2px 3px 15px 0 #ccc;
}
</style>